package com.java110.mall.cart.smo.impl;


import com.java110.mall.cart.dao.IHousekeepingFeeConfigServiceDao;
import com.java110.dto.housekeeping.HousekeepingFeeConfigDto;
import com.java110.dto.housekeeping.HousekeepingServFeeDto;
import com.java110.intf.cart.IHousekeepingFeeConfigInnerServiceSMO;
import com.java110.po.housekeeping.HousekeepingFeeConfigPo;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 费用标准内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class HousekeepingFeeConfigInnerServiceSMOImpl extends BaseServiceSMO implements IHousekeepingFeeConfigInnerServiceSMO {

    @Autowired
    private IHousekeepingFeeConfigServiceDao housekeepingFeeConfigServiceDaoImpl;


    @Override
    public int saveHousekeepingFeeConfig(@RequestBody HousekeepingFeeConfigPo housekeepingFeeConfigPo) {
        int saveFlag = 1;
        housekeepingFeeConfigServiceDaoImpl.saveHousekeepingFeeConfigInfo(BeanConvertUtil.beanCovertMap(housekeepingFeeConfigPo));
        return saveFlag;
    }

     @Override
    public int updateHousekeepingFeeConfig(@RequestBody  HousekeepingFeeConfigPo housekeepingFeeConfigPo) {
        int saveFlag = 1;
         housekeepingFeeConfigServiceDaoImpl.updateHousekeepingFeeConfigInfo(BeanConvertUtil.beanCovertMap(housekeepingFeeConfigPo));
        return saveFlag;
    }

     @Override
    public int deleteHousekeepingFeeConfig(@RequestBody  HousekeepingFeeConfigPo housekeepingFeeConfigPo) {
        int saveFlag = 1;
        housekeepingFeeConfigPo.setStatusCd("1");
        housekeepingFeeConfigServiceDaoImpl.updateHousekeepingFeeConfigInfo(BeanConvertUtil.beanCovertMap(housekeepingFeeConfigPo));
        return saveFlag;
    }

    @Override
    public List<HousekeepingFeeConfigDto> queryHousekeepingFeeConfigs(@RequestBody  HousekeepingFeeConfigDto housekeepingFeeConfigDto) {

        //校验是否传了 分页信息

        int page = housekeepingFeeConfigDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            housekeepingFeeConfigDto.setPage((page - 1) * housekeepingFeeConfigDto.getRow());
        }

        List<HousekeepingFeeConfigDto> housekeepingFeeConfigs = BeanConvertUtil.covertBeanList(housekeepingFeeConfigServiceDaoImpl.getHousekeepingFeeConfigInfo(BeanConvertUtil.beanCovertMap(housekeepingFeeConfigDto)), HousekeepingFeeConfigDto.class);

        return housekeepingFeeConfigs;
    }

    @Override
    public List<HousekeepingFeeConfigDto> queryHousekeepingServFeeConfigs(@RequestBody HousekeepingServFeeDto housekeepingServFeeDto) {
        //校验是否传了 分页信息

        int page = housekeepingServFeeDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            housekeepingServFeeDto.setPage((page - 1) * housekeepingServFeeDto.getRow());
        }

        List<HousekeepingFeeConfigDto> housekeepingFeeConfigs = BeanConvertUtil.covertBeanList(housekeepingFeeConfigServiceDaoImpl.getHousekeepingServFeeConfigInfo(BeanConvertUtil.beanCovertMap(housekeepingServFeeDto)), HousekeepingFeeConfigDto.class);

        return housekeepingFeeConfigs;
    }


    @Override
    public int queryHousekeepingFeeConfigsCount(@RequestBody HousekeepingFeeConfigDto housekeepingFeeConfigDto) {
        return housekeepingFeeConfigServiceDaoImpl.queryHousekeepingFeeConfigsCount(BeanConvertUtil.beanCovertMap(housekeepingFeeConfigDto));    }

    public IHousekeepingFeeConfigServiceDao getHousekeepingFeeConfigServiceDaoImpl() {
        return housekeepingFeeConfigServiceDaoImpl;
    }

    public void setHousekeepingFeeConfigServiceDaoImpl(IHousekeepingFeeConfigServiceDao housekeepingFeeConfigServiceDaoImpl) {
        this.housekeepingFeeConfigServiceDaoImpl = housekeepingFeeConfigServiceDaoImpl;
    }
}
